package com.util.mail;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class Test {

	public static void main(String[] args) {
		try {
			sendMail("test","<h1>今天场务没有问题呢</h1><br><br><br>祝好！<br>赖建波");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 * 
	 */
	private static void sendMail(String subject,String content) throws FileNotFoundException, IOException {
		Properties properties = new Properties();
		properties.load(new FileInputStream("src/mail.properties"));
		// 这个类主要是设置邮件
		MailSenderInfo mailInfo = new MailSenderInfo();
		mailInfo.setMailServerHost(properties.getProperty("serverHost"));
		mailInfo.setValidate(true);
		mailInfo.setMailServerPort(properties.getProperty("serverPort"));
		mailInfo.setUserName(properties.getProperty("fromAddress"));
		mailInfo.setPassword(properties.getProperty("fromAddressPassword"));// 您的邮箱密码
		mailInfo.setFromAddress(properties.getProperty("fromAddress"));
		mailInfo.setToAddress(properties.getProperty("toAddress"));
		mailInfo.setSubject(subject);
		mailInfo.setContent(content);
		// 这个类主要来发送邮件
//		SimpleMailSender.sendTextMail(mailInfo);// 发送文体格式
		SimpleMailSender.sendHtmlMail(mailInfo);// 发送html格式
	}
}
